<?php
	include_once "../classes/submenu_bs.php";
	include_once "../classes/thuvienham.php";
	
	if(!IsAdmin())
		header("Location: index.php");
	if(isset($_GET['id']) && isset($_GET['pin']))
	{
		$MaMenu = $_GET['id'];
		$PIN = isset($_GET['pin']);
		
		$menu = new submenu_bs();
		$menu->SetMaSubMenu($MaMenu);
		$menu_data = $menu->LayDanhSach();
		if($menu_data != null)
		{
			$new_TT = $menu_data[0]['TrangThai'] == 1 ? 0 : 1;
			$menu = new submenu_bs();
			$menu->SetMaSubMenu($MaMenu);
			$menu->SetTrangThai($new_TT);
			$menu->CapNhatTrangThai();
			
			$menu->SetPin(GeneratePIN());
			$menu->CapNhatPIN();
		}
	}
	QuayVeTrangTruoc();
?>